import 'package:flutter/cupertino.dart';
import 'package:hc_ui/config/hc_customer_config.dart';
import 'package:hc_ui/config/hc_default_theme_config.dart';
import 'package:hc_ui/theme/hc_base_theme.dart';

import 'hc_common_theme.dart';

class HcToastTheme extends HcBaseTheme<HcToastTheme> {
  /// 带图标和文字时候的Padding 默认18.0
  EdgeInsets? _padding;

  ///仅文字时候的padding v:8h:12
  EdgeInsets? _textPadding;

  /// 距离边框的距离 默认为40
  EdgeInsets? _margin;

  //文字和icon之间的间距默认为8
  double? _spacing;

  ///背景颜色 默认为0xff222222
  Color? _background;

  /// 距离顶部/底部边框的距离 默认50
  double? _verticalMargin;

  ///圆角 默认8
  double? _borderRadius;

  ///文字大小 默认14
  double? _fontSize;

  ///只有文字时最小宽度 默认96
  double? _textMinWidth;

  double? _minWidth;
  double? _minHeight;
  double? _iconSize;

  HcToastTheme({
    EdgeInsets? padding,
    EdgeInsets? textPadding,
    EdgeInsets? margin,
    double? spacing,
    Color? background,
    double? verticalMargin,
    double? borderRadius,
    double? fontSize,
    double? minWidth,
    double? textMinWidth,
    double? minHeight,
    double? iconSize,
  })  : _padding = padding,
        _textPadding = textPadding,
        _margin = margin,
        _spacing = spacing,
        _background = background,
        _verticalMargin = verticalMargin,
        _borderRadius = borderRadius,
        _fontSize = fontSize,
        _textMinWidth = textMinWidth,
        _iconSize = iconSize,
        _minHeight = minHeight,
        _minWidth = minWidth;

  @override
  initTheme({HcCommonTheme? tempTheme}) {
    super.initTheme(tempTheme: tempTheme);
    HcToastTheme toastTheme = HcCustomerConfig().allTheme.toastTheme;
    _padding ??= toastTheme._padding;
    _textPadding ??= toastTheme._textPadding;
    _margin ??= toastTheme._margin;
    _spacing ??= commonTheme.vSpacingBase;
    _background ??= toastTheme._background;
    _verticalMargin ??= toastTheme._verticalMargin;
    _borderRadius ??= commonTheme.radiusBase;
    _fontSize ??= commonTheme.fontSizeSubtitle;
    _textMinWidth ??= toastTheme._textMinWidth;
    _minHeight ??= toastTheme._minHeight;
    _minWidth ??= toastTheme._minWidth;
    _iconSize ??= commonTheme.iconSizeLg;
  }

  @override
  HcToastTheme merge(HcToastTheme? value) {
    if (value == null) return this;
    return copyWith(
        padding: value._padding,
        textPadding: value._textPadding,
        margin: value._margin,
        spacing: value._spacing,
        background: value._background,
        verticalMargin: value._verticalMargin,
        borderRadius: value._borderRadius,
        fontSize: value._fontSize,
        textMinWidth: value._textMinWidth,
        iconSize: value._iconSize,
        minHeight: value._minHeight,
        minWidth: value._minWidth);
  }

  copyWith(
      {EdgeInsets? padding,
      EdgeInsets? textPadding,
      EdgeInsets? margin,
      double? spacing,
      Color? background,
      double? verticalMargin,
      double? borderRadius,
      double? fontSize,
      double? textMinWidth,
      double? iconSize,
      double? minHeight,
      double? minWidth}) {
    return HcToastTheme(
        padding: padding ?? _padding,
        textPadding: textPadding ?? _textPadding,
        textMinWidth: textMinWidth ?? _textMinWidth,
        margin: margin ?? _margin,
        spacing: spacing ?? _spacing,
        background: background ?? _background,
        verticalMargin: verticalMargin ?? _verticalMargin,
        borderRadius: borderRadius ?? _borderRadius,
        fontSize: fontSize ?? _fontSize,
        iconSize: iconSize ?? _iconSize,
        minWidth: minWidth ?? _minWidth,
        minHeight: minHeight ?? _minHeight);
  }

  EdgeInsets get padding =>
      _padding ?? HcDefaultThemeConfig.defaultToastTheme.padding;



  EdgeInsets get margin =>
      _margin ?? HcDefaultThemeConfig.defaultToastTheme.margin;


  double get spacing =>
      _spacing ?? HcDefaultThemeConfig.defaultToastTheme.spacing;



  Color get background =>
      _background ?? HcDefaultThemeConfig.defaultToastTheme.background;


  double get verticalMargin =>
      _verticalMargin ?? HcDefaultThemeConfig.defaultToastTheme.verticalMargin;


  double get borderRadius =>
      _borderRadius ?? HcDefaultThemeConfig.defaultToastTheme.borderRadius;

  double get fontSize =>
      _fontSize ?? HcDefaultThemeConfig.defaultToastTheme.fontSize;

  double get minHeight =>
      _minHeight ?? HcDefaultThemeConfig.defaultToastTheme.minHeight;


  double get minWidth =>
      _minWidth ?? HcDefaultThemeConfig.defaultToastTheme.minWidth;

  EdgeInsets get textPadding =>
      _textPadding ?? HcDefaultThemeConfig.defaultToastTheme.textPadding;


  double get textMinWidth =>
      _textMinWidth ?? HcDefaultThemeConfig.defaultToastTheme.textMinWidth;


  double get iconSize =>
      _iconSize ?? HcDefaultThemeConfig.defaultToastTheme.iconSize;

}
